package question4;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Order {
    private Date createDate;
    private OrderStatus status;
    private Customer customer; // 关联的客户
    private Payment payment;
    private List<OrderDetail> orderDetails = new ArrayList<>(); // 关联的订单详情

    // 构造方法
    public Order(Date createDate, OrderStatus status) {
        this.createDate = createDate;
        this.status = status;
    }

    // Getter和Setter方法
    public Date getCreateDate() {
        return createDate;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Payment getPayment() {
        return payment;
    }

    public void setPayment(Payment payment) {
        this.payment = payment;
    }

    // 关联订单详情的方法
    public List<OrderDetail> getOrderDetails() {
        return orderDetails;
    }

    public void addOrderDetail(OrderDetail orderDetail) {
        orderDetails.add(orderDetail);
        orderDetail.setOrder(this);     // 双向关联
    }
}
